﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.Design;
using Terralever.Facebook.UI.FbmlControls;

namespace Terralever.Facebook.UI.Design.FbmlControls
{
    public class FbPronounDesigner : FbmlControlDesigner
    {
        public override string GetDesignTimeHtml()
        {
            if (Component == null)
                return base.GetDesignTimeHtml();

            Pronoun nameControl = Component as Pronoun;
            if (nameControl == null)
                return base.GetDesignTimeHtml();

            StringBuilder sb = new StringBuilder();

            if (nameControl.UseThey)
            {
                if (nameControl.Capitalize)
                {
                    sb.Append("T");
                }
                else
                {
                    sb.Append("t");
                }

                if (nameControl.Reflexive)
                {
                    sb.Append("hemselves");
                }
                else if (nameControl.Objective)
                {
                    sb.Append("hem");
                }
                else if (nameControl.Possessive)
                {
                    sb.Append("heir");
                }
                else
                {
                    sb.Append("hey");
                }
            }
            else if (nameControl.UseYou)
            {
                if (nameControl.Capitalize)
                {
                    sb.Append("Y");
                }
                else
                {
                    sb.Append("y");
                }

                if (nameControl.Reflexive)
                {
                    sb.Append("ourself");
                }
                else if (nameControl.Objective)
                {
                    sb.Append("ou");
                }
                else if (nameControl.Possessive)
                {
                    sb.Append("our");
                }
                else
                {
                    sb.Append("ou");
                }
            }
            else
            {
                if (nameControl.Capitalize)
                {
                    sb.Append("H");
                }
                else
                {
                    sb.Append("h");
                }

                if (nameControl.Reflexive)
                {
                    sb.Append("imself");
                }
                else if (nameControl.Objective)
                {
                    sb.Append("im");
                }
                else if (nameControl.Possessive)
                {
                    sb.Append("is");
                }
                else
                {
                    sb.Append("e");
                }
            }

            return sb.ToString();
        }
    }
}
